import os
import sys

# 请在此输入您的代码
n = int(input())
data1 = []
data2 = []
for i in range(n):
  data = list(map(int,input().split()))
  data1.append(data[0]+data[1])
  data2.append(sum(data))

data1.sort()
data2.sort()

res = 0


for d in data1:
  res += d

# print(res)
for i in range(n):
  res += data2[i] * (n-i-1)

print(res)

